<template>
    <el-card v-if="loginRole === 'root' || loginRole === 'emp' || loginRole === 'admin'">
        <RootView />
    </el-card>
    <el-card v-if="loginRole === 'user'">
        <IndexView />
    </el-card>
</template>

<script setup>
import userApi from '@/api/userApi';
import IndexView from '@/components/IndexView.vue';
import RootView from '@/components/RootView.vue';
import { onMounted, ref, onBeforeMount } from 'vue';

const loginRole = ref('');

// 获取父组件传递的值
let props = defineProps({ role: '' });

const getInfo = async () => {
    // let role = props.role;
    // let role = sessionStorage.getItem('userRole');

    let resp = await userApi.getById(0);

    if (resp.code === 10000) {
        loginRole.value = resp.data.role;
        console.log(resp.data.role);
    }
    // console.log(role);
    // loginRole.value = role;
}

onBeforeMount(() => {
    getInfo();
})

</script>

<style scoped></style>
